package com.dingwen.treasure.auth.service.impl;

import com.dingwen.treasure.auth.service.LoginService;
import com.dingwen.treasure.auth.service.TokenService;
import com.dingwen.treasure.common.redis.service.RedisService;
import com.dingwen.treasure.model.vo.LoginVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


/**
 * 　LoginServiceImpl
 * 　@author dingwen
 * 　@date 2022/6/12
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class LoginServiceImpl implements LoginService {


    /**
     * redis 服务
     */
    @Resource
    private  RedisService redisService;

    /**
     * tokenService
     */
    @Resource
    private  TokenService tokenService;


    /**
     * 登录
     *
     * @param account  账号
     * @param password 密码
     * @return {@link LoginVo}
     */
    @Override
    public String login(String account, String password) {
        // 账号密码正确
        // 缓存用户信息
        // 生成token  返回
        // token 缓存
        // easy cache 实现
        // 失败抛出异常
        // 权限实现类似后台
        //TODO 自己实现用户表登录 user,目前简单返回token
        return tokenService.generateAppToken(account, password);
    }
}
